<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>应急信息发布项目审核查看</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet" type="text/css">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script>
        layui.use(['form', 'jquery', 'element', 'laydate', 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;
            var laydate = layui.laydate;
            var layer = layui.layer;
            var checkId = getUrlParam("checkId");
            var userDuty = getUrlParam("userDuty")
            var checkDetail;

            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
            $('#yes').on('click', function () {
                var param = {
                    checkId: checkId
                };
                var url = '/xuYiContentCheck/dealCheckResult';
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        if ($("#remark").val() == "") {
                            layer.msg("审核说明不能为空");
                            return false;
                        }
                        updateCheckState('1');
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) { 						
                        layer.close(loading);

                        var data = json.data;
                        if (json.retCode == 0) {
                            /*layui.use('layer', function () {
                                layer.msg('审核成功，点击确定按钮返回审核页面', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index) {
                                        layer.close(index);
                                        location.href = "xuYiContentCheck.html";
                                    }
                                });
                            });*/

                            layer.confirm('审核成功，点击确定按钮返回审核页面', {
                                btn: ['确定'], //按钮
                                closeBtn:0
                            }, function () {
                                location.href = "xuYiContentCheck.html";
                            });
                            /*layer.open({
                                content: '审核成功，点击确定按钮返回审核页面'
                                ,btn: ['确定']
                            }, function () {
                                location.href = "xuYiContentCheck.html";
                            });*/
                        } else {
                            console.info("1111")
                        }
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });

            $('#no').on('click', function () {
                if ($("#remark").val() == "") {
                    layer.msg("审核说明不能为空");
                    return false;
                }
                updateCheckState('2');
                layui.use('layer', function () {
                    /*layer.msg('审核成功，点击确定按钮返回审核页面', {
                        time: 0 //不自动关闭
                        , btn: ['确定']
                        , yes: function (index) {
                            layer.close(index);
                            location.href = "xuYiContentCheck.html";
                        }
                    });*/

                    layer.confirm('审核成功，点击确定按钮返回审核页面', {
                        btn: ['确定'], //按钮
                        closeBtn:0
                    }, function () {
                        location.href = "xuYiContentCheck.html";
                    });

                    /*layer.open({
                        content: '审核成功，点击确定按钮返回审核页面'
                        ,btn: ['确定']
                    }, function () {
                        location.href = "xuYiContentCheck.html";
                    });*/

                });
            });

            //变更短信内容审核表中的审核状态
            function updateCheckState(checkState){
                var url = '/xuYiContentCheck/updateCheckInfo'
                var param = {
                    checkState : checkState,
                    remark : $("#remark").val(),
                    checkId : checkId
                }
                $.ajax({
                    contentType:"application/json;charset=UTF-8",
                    type: 'post',
                    async: false,
                    url: url,
                    data: JSON.stringify(param),
                    dataType:'json',
                    success: function (json) {
                        layer.close(loading);
                        console.info("审核表状态已改变")
                    },
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            }

            function jugdeDuty(){

                if(userDuty=="1"||userDuty=="0"){
                    $('#yes')[0].style.display = 'inline-block';
                    $('#no')[0].style.display = 'inline-block';
                }

                if(userDuty == "7"||checkDetail.checkState =="1"||checkDetail.checkState =="2"){
                    $('#yes').hide();
                    $('#no').hide();
                    $("#back")[0].style.display = "inline-block";
                }
                if(userDuty == "7"&&checkDetail.checkState =="0"){
                    //$('#checkRemark').hide();
                    $('#remark').attr("disabled",true);
                    $("#back")[0].style.display = "inline-block";
                }
            }

            function findCheckDetail(){
                var url = '/xuYiContentCheck/findCheckDetail';
                console.info(checkId);
                var param = {
                    checkId: checkId
                };
                $.ajax({
                    contentType:"application/json;charset=UTF-8",
                    type: 'post',
                    async: false,
                    url: url,
                    data: JSON.stringify(param),
                    dataType:'json',
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        checkDetail= json.data;
                        console.info(checkDetail);
                        //$("#startTime").val(data.startDate);
                        //$("#endTime").val(data.endDate);
                        $('#contentTempName').val(checkDetail.contentTempName);
                        $('#contentTemp').val(checkDetail.contentTemp);

                        //console.info(JSON.stringify(data));
                        //$('#countyName').val(data.countyName);
                        //$('#mgrName').val(data.mgrName);
                        if("0"==checkDetail.checkState){
                            $('#checkState').val("待审核");
                            $("#back")[0].style.display = "none";
                        }else if("1"==checkDetail.checkState){
                            $('#checkState').val("审核通过");
                            $('#remark').val(checkDetail.remark);
                            $('#remark').attr("disabled",true);
                            $("#back")[0].style.display = "inline-block";
                        }else if("2"==checkDetail.checkState){
                            $('#checkState').val("审核不通过");
                            $('#remark').val(checkDetail.remark);
                            $('#remark').attr("disabled",true);
                            $("#back")[0].style.display = "inline-block";
                        }
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            }

            $('#back').on('click', function (){
                location.href = "xuYiContentCheck.html";
            });


            //页面数据初始化
            $(document).ready(function () {
                findCheckDetail();
                jugdeDuty();
            });
        });
    </script>
</head>
<body>
<div class="layui-html-limit">
    <div class="layui-content-body">
        <div class="scroll-box">
            <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
     <a href="javascript:returnIndex2()">首页&nbsp;</a>
     <a href="#"> &nbsp;短信模板内容审核&nbsp; </a>
</span>
         </div>
         <div class="content-box">
         <div class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label">模板名称</label>
                            <div class="layui-input-block">
                                <input type="text" style="width:auto"
                                       id="contentTempName" autocomplete="off" class="layui-input" disabled>
                            </div>
                        </div>
                    </div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label">模板内容</label>
									<div class="layui-input-block">
										<textarea placeholder="请输入内容" class="layui-textarea"
											style="width: 30%" id="contentTemp" disabled></textarea>
									</div>
								</div>
							</div>
                    <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label">审核状态</label>
                                <div class="layui-input-block">
                                    <input type="text" style="width:auto"
                                            id="checkState" autocomplete="off" class="layui-input" disabled>
                                </div>
                        </div>
                    </div>
							<!--  <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width: auto">发送起止时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="startTime" autocomplete="off" class="layui-input"
                                       disabled>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="endTime" autocomplete="off" class="layui-input"
                                       disabled>
                            </div>
                        </div>
                    </div> -->
							<div class="layui-form-item" id = "checkRemark">
								<label class="layui-form-label">审核说明</label>
								<div class="layui-input-block">
									<textarea placeholder="请输入内容" class="layui-textarea"
										style="width: 30%" id="remark"></textarea>
								</div>
							</div>
							<div class="layui-form-item">
								<button class="layui-btn layui-btn-normal" id="yes" style = 'display: none;'>审核通过</button>
								<button class="layui-btn layui-btn-danger" id="no" style = 'display: none;'>审核不通过</button>
                                <button class="layui-btn layui-btn-normal" id="back" style="display:none">返回</button>
							</div>
						</div>
					</div>
        </div>
    </div>
</div>
</div>

</body>
</html>